﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataProcessDoc" @search="()=>{getTableDataProcessDoc();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RouteId_FormItem" prop="RouteId" :label="$t('message.autotrans._Model_ProcessDoc_Route')">
            <el-select v-model="searchDataProcessDoc.RouteId" clearable>
               <el-option v-for="item in stateProcessDoc.AllRoutes" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_ProcessDoc_Op')">
            <el-select v-model="searchDataProcessDoc.OpId" clearable>
               <el-option v-for="item in stateProcessDoc.AllOps" :key="item.Value" :value="item.Value" :label="item.Text"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpCode_FormItem" prop="OpCode" :label="$t('message.autotrans._Model_ProcessDoc_OpCode')">
            <el-input v-model="searchDataProcessDoc.OpCode" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_ProcessDoc_ProductId')">
            <el-input v-model="searchDataProcessDoc.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="FileName_FormItem" prop="FileName" :label="$t('message.autotrans._Model_ProcessDoc_FileName')">
            <el-input v-model="searchDataProcessDoc.FileName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="FileType_FormItem" prop="FileType" :label="$t('message.autotrans._Model_ProcessDoc_FileType')">
            <el-input v-model="searchDataProcessDoc.FileType" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RemotePc_FormItem" prop="RemotePc" :label="$t('message.autotrans._Model_ProcessDoc_RemotePc')">
            <el-input v-model="searchDataProcessDoc.RemotePc" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="RemotePath_FormItem" prop="RemotePath" :label="$t('message.autotrans._Model_ProcessDoc_RemotePath')">
            <el-input v-model="searchDataProcessDoc.RemotePath" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UserName_FormItem" prop="UserName" :label="$t('message.autotrans._Model_ProcessDoc_UserName')">
            <el-input v-model="searchDataProcessDoc.UserName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Pwd_FormItem" prop="Pwd" :label="$t('message.autotrans._Model_ProcessDoc_Pwd')">
            <el-input v-model="searchDataProcessDoc.Pwd" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_ProcessDoc_CreateTime')">
            <el-date-picker v-model="searchDataProcessDoc.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_ProcessDoc_UpdateTime')">
            <el-date-picker v-model="searchDataProcessDoc.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_ProcessDoc_CreateBy')">
            <el-input v-model="searchDataProcessDoc.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_ProcessDoc_UpdateBy')">
            <el-input v-model="searchDataProcessDoc.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/ProcessDocExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefProcessDoc" v-bind="tableDataProcessDoc">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/ProcessManagement/ProcessDoc/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageProcessManagementProcessDocIndex;true;Digitalmes.ProcessManagement.Controllers;ProcessDoc">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { processdocApi } from '/@/api/processmanagement/processdoc';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateProcessDoc = reactive({
    
    AllRoutes: [] as any[],
    AllOps: [] as any[],
});

const searchDataProcessDoc = ref({
        RouteId: null,
        OpId: null,
        OpCode: '',
        ProductId: null,
        FileName: '',
        FileType: '',
        RemotePc: '',
        RemotePath: '',
        UserName: '',
        Pwd: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefProcessDoc = ref();
const tableDataProcessDoc = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page工艺路线'),key: 'ProcessDoc_Route',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序'),key: 'ProcessDoc_Op',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page工序编号'),key: 'ProcessDoc_OpCode',type: 'text',isCheck: true},
      // {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'ProcessDoc_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page文件名称'),key: 'ProcessDoc_FileName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page文件类型'),key: 'ProcessDoc_FileType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page远程主机'),key: 'ProcessDoc_RemotePc',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page远程主机目录'),key: 'ProcessDoc_RemotePath',type: 'text',colWidth:150,isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page用户名'),key: 'ProcessDoc_UserName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminPassword'),key: 'ProcessDoc_Pwd',type: 'text',isCheck: true},

		{title:ci.proxy.$t('message.autotrans.Page激活'),key: 'ProcessDoc_Active',type: 'switch',isCheck: true},
		{title:ci.proxy.$t('message.autotrans._AdminCreateTime'),key: 'ProcessDoc_CreateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateTime'),key: 'ProcessDoc_UpdateTime',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminCreateBy'),key: 'ProcessDoc_CreateBy',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminUpdateBy'),key: 'ProcessDoc_UpdateBy',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataProcessDoc = () => {
    tableRefProcessDoc.value.doSearch(processdocApi().search, searchDataProcessDoc.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataProcessDoc)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataProcessDoc)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataProcessDoc)
};

// 删除
const onDelete = (row: any) => {
    processdocApi().delete([row.ID]).then(() => { getTableDataProcessDoc()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefProcessDoc.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      processdocApi().delete(selectedids).then(() => { getTableDataProcessDoc()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefProcessDoc.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataProcessDoc)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataProcessDoc)
};

const onExport = () => {
	const selected = tableRefProcessDoc.value.getSelectedRows();
	if (selected.length > 0) {
		processdocApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		processdocApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
    other.getSelectList('/api/ProcessManagement/ProcessDoc/GetProcessRoutes',[],false).then(x=>{stateProcessDoc.AllRoutes = x});
    other.getSelectList('/api/ProcessManagement/ProcessDoc/GetProcessRouteItems',[],false).then(x=>{stateProcessDoc.AllOps = x});
        getTableDataProcessDoc();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

